<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>gamvas.AStarMap</title><link rel="stylesheet" type="text/css" href="../styles/main.css"><script language=JavaScript src="../javascript/main.js"></script><script language=JavaScript src="../javascript/prettify.js"></script><script language=JavaScript src="../javascript/searchdata.js"></script></head><body class="ContentPage" onLoad="NDOnLoad();prettyPrint();"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>

<!--  Generated by Natural Docs, version 1.51 -->
<!--  http://www.naturaldocs.org  -->

<!-- saved from url=(0026)http://www.naturaldocs.org -->




<div id=Content><div class="CClass"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="gamvas.AStarMap"></a>gamvas.<wbr>AStarMap</h1><div class=CBody><h4 class=CHeading>Description</h4><p>A flexible 3D node based A* pathfinding system</p><p>For a simpler to use 2D grid based system, have a look at <a href="gamvas-astargrid-js.html#gamvas.AStarGrid" class=LClass id=link5 onMouseOver="ShowTip(event, 'tt4', 'link5')" onMouseOut="HideTip('tt4')">gamvas.AStarGrid</a></p><h4 class=CHeading>Constructor</h4><p>new gamvas.AStarMap(withFirst);</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>withFirst</td><td class=CDLDescription>include the first element of a path when searching (optional, default: true) Example:</td></tr></table><p>Create a new path finding system and add two nodes that are connected to each other.</p><blockquote><pre>var pathFind = new gamvas.AStarMap();
// create nodes
var n1 = new AStarNode(10, 2);
var n2 = new AStarNode(100, 50);
// set connection between nodes
n1.connect(n2);
// add the nodes to the system
pathFind.add(n1);
pathFind.add(n2);
// find the path between two points in space
var path = pathFind.find(5, 1, 120, 40);</pre></blockquote><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SMain"><td class=SEntry><a href="#gamvas.AStarMap" >gamvas.<wbr>AStarMap</a></td><td class=SDescription>A flexible 3D node based A* pathfinding system</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#gamvas.AStarMap.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#gamvas.AStarMap.add" id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">add</a></td><td class=SDescription>Add a <a href="gamvas-astarnode-js.html#gamvas.AStarNode" class=LClass id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">gamvas.AStarNode</a> to the node system</td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#gamvas.AStarMap.find" id=link3 onMouseOver="ShowTip(event, 'tt3', 'link3')" onMouseOut="HideTip('tt3')">find</a></td><td class=SDescription>Find a path between two points in 2D space, or two <a href="gamvas-astarnode-js.html#gamvas.AStarNode" class=LClass id=link4 onMouseOver="ShowTip(event, 'tt2', 'link4')" onMouseOut="HideTip('tt2')">gamvas.AStarNode</a> elements</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="gamvas.AStarMap.Functions"></a>Functions</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gamvas.AStarMap.add"></a>add</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>add: function(</td><td class="PParameter  prettyprint " nowrap>n</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Add a <a href="gamvas-astarnode-js.html#gamvas.AStarNode" class=LClass id=link6 onMouseOver="ShowTip(event, 'tt2', 'link6')" onMouseOut="HideTip('tt2')">gamvas.AStarNode</a> to the node system</p><h4 class=CHeading>Note</h4><p>Keep in mind, that by just adding it, it is not connected to anything.&nbsp; See <a href="gamvas-astarnode-js.html#gamvas.AStarNode.connect" class=LFunction id=link7 onMouseOver="ShowTip(event, 'tt5', 'link7')" onMouseOut="HideTip('tt5')">gamvas.AStarNode.connect</a></p></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gamvas.AStarMap.find"></a>find</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>find: function(</td><td class="PParameter  prettyprint " nowrap>nxs,</td></tr><tr><td></td><td class="PParameter  prettyprint " nowrap>nys,</td></tr><tr><td></td><td class="PParameter  prettyprint " nowrap>xe,</td></tr><tr><td></td><td class="PParameter  prettyprint " nowrap>ye</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p>Find a path between two points in 2D space, or two <a href="gamvas-astarnode-js.html#gamvas.AStarNode" class=LClass id=link8 onMouseOver="ShowTip(event, 'tt2', 'link8')" onMouseOut="HideTip('tt2')">gamvas.AStarNode</a> elements</p><h4 class=CHeading>Parameters</h4><p>This function has two alternative ways to use it</p><h4 class=CHeading>A) by specifying points in 2D space</h4><p>map.find(x1, y1, x2, y2);</p><h4 class=CHeading>B) by specifying nodes</h4><p>map.find(node1, node2);</p><h4 class=CHeading>Example</h4><blockquote><pre>var pathFind = new gamvas.AStarMap();
// create nodes
var n1 = new AStarNode(10, 2);
var n2 = new AStarNode(100, 50);
var n3 = new AStarNode(250, 25);
// set connection between nodes
n1.connect(n2);
n2.connect(n3);
// add the nodes to the system
pathFind.add(n1);
pathFind.add(n2);
pathFind.add(n3);
// find the path using the nodes instead of using 3d coordinates
var path = pathFind.find(n1, n3);</pre></blockquote></div></div></div>

</div><!--Content-->


<div id=Footer><a href="http://www.naturaldocs.org">Generated by Natural Docs</a></div><!--Footer-->


<div id=Menu><div class=MEntry><div class=MFile><a href="gamvas-base-js.html">gamvas</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-actor-js.html">gamvas.<wbr>Actor</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-actorstate-js.html">gamvas.<wbr>ActorState</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-animation-js.html">gamvas.<wbr>Animation</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-astar-js.html">gamvas.<wbr>AStar</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-astargrid-js.html">gamvas.<wbr>AStarGrid</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-astargridnode-js.html">gamvas.<wbr>AStarGridNode</a></div></div><div class=MEntry><div class=MFile id=MSelected>gamvas.<wbr>AStarMap</div></div><div class=MEntry><div class=MFile><a href="gamvas-astarnode-js.html">gamvas.<wbr>AStarNode</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-camera-js.html">gamvas.<wbr>Camera</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-class-js.html">gamvas.<wbr>Class</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-config-js.html">gamvas.<wbr>config</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-dom-js.html">gamvas.dom</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-event-js.html">gamvas.<wbr>event</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-image-js.html">gamvas.<wbr>Image</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-key-js.html">gamvas.key</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-math-js.html">gamvas.math</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-mouse-js.html">gamvas.<wbr>mouse</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-particleemitter-js.html">gamvas.<wbr>ParticleEmitter</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-physics-js.html">gamvas.<wbr>physics</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-physics-userdata-js.html">gamvas.<wbr>physics.<wbr>UserData</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-rect-js.html">gamvas.Rect</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-resource-js.html">gamvas.<wbr>Resource</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-screen-js.html">gamvas.<wbr>screen</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-sound-js.html">gamvas.<wbr>Sound</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-state-js.html">gamvas.<wbr>state</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-state-state-js.html">gamvas.<wbr>State</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-timer-js.html">gamvas.<wbr>timer</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-vector2d-js.html">gamvas.<wbr>Vector2D</a></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent1')">Index</a><div class=MGroupContent id=MGroupContent1><div class=MEntry><div class=MIndex><a href="../index/General.html">Everything</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Classes.html">Classes</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Functions.html">Functions</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Macros.html">Macros</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Variables.html">Variables</a></div></div></div></div></div><script type="text/javascript"><!--
var searchPanel = new SearchPanel("searchPanel", "HTML", "../search");
--></script><div id=MSearchPanel class=MSearchPanelInactive><input type=text id=MSearchField value=Search onFocus="searchPanel.OnSearchFieldFocus(true)" onBlur="searchPanel.OnSearchFieldFocus(false)" onKeyUp="searchPanel.OnSearchFieldChange()"><select id=MSearchType onFocus="searchPanel.OnSearchTypeFocus(true)" onBlur="searchPanel.OnSearchTypeFocus(false)" onChange="searchPanel.OnSearchTypeChange()"><option  id=MSearchEverything selected value="General">Everything</option><option value="Classes">Classes</option><option value="Functions">Functions</option><option value="Macros">Macros</option><option value="Variables">Variables</option></select></div><script language=JavaScript><!--
HideAllBut([], 2);// --></script></div><!--Menu-->



<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>add: function(</td><td class="PParameter  prettyprint " nowrap>n</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Add a gamvas.AStarNode to the node system</div></div><div class=CToolTip id="tt2"><div class=CClass>A base class for pathfinding nodes. </div></div><div class=CToolTip id="tt3"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>find: function(</td><td class="PParameter  prettyprint " nowrap>nxs,</td></tr><tr><td></td><td class="PParameter  prettyprint " nowrap>nys,</td></tr><tr><td></td><td class="PParameter  prettyprint " nowrap>xe,</td></tr><tr><td></td><td class="PParameter  prettyprint " nowrap>ye</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Find a path between two points in 2D space, or two gamvas.AStarNode elements</div></div><div class=CToolTip id="tt4"><div class=CClass>A class to simplify A* pathfinding on a 2x2 grid with a optional height field</div></div><div class=CToolTip id="tt5"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>connect: function(</td><td class="PParameter  prettyprint " nowrap>n,</td></tr><tr><td></td><td class="PParameter  prettyprint " nowrap>auto</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Connect two nodes</div></div><!--END_ND_TOOLTIPS-->




<div id=MSearchResultsWindow><iframe src="" frameborder=0 name=MSearchResults id=MSearchResults></iframe><a href="javascript:searchPanel.CloseResultsWindow()" id=MSearchResultsWindowClose>Close</a></div>


<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>